package com.heima.admin.controller.v1;



import com.heima.admin.service.SensitiveService;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "敏感词管理api接口",tags = "敏感词管理api接口")
@RestController
@RequestMapping("/api/v1/sensitive")
public class SensitiveController {

    @Autowired
    private SensitiveService sensitiveService;

    /**
     * 分页查询敏感词数据
     * @param dto
     * @return
     */
    @ApiOperation(value = "分页条件查询频道列表")
    @PostMapping("/list")
    public ResponseResult list(@RequestBody SensitiveDto dto){
        return sensitiveService.getSensitive(dto);
    }

    /**
     * 添加敏感词数据
     * @param sensitive
     * @return
     */
    @ApiOperation(value = "添加数据")
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody AdSensitive sensitive){
        return sensitiveService.saveSensitive(sensitive);
    }

    /**
     * 修改敏感词数据
     * @param sensitive
     * @return
     */
    @ApiOperation(value = "修改数据")
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody AdSensitive sensitive){
        return sensitiveService.updateSensitive(sensitive);
    }


    /**
     * 删除敏感词数据
     * @param
     * @return
     */
    @ApiOperation(value = "删除数据")
    @DeleteMapping("/del/{id}")
    public ResponseResult deleteSensitive(@PathVariable("id") Integer id){
        return sensitiveService.deleteSensitive(id);
    }


    /**
     * 查询敏感词
     * @param
     * @return
     */
    @ApiOperation(value = "查询敏感词")
    @DeleteMapping("/sensitives")
    public ResponseResult<List<String>> selectAllSensitives(){
        return sensitiveService.selectAllSensitives();
    }







}
